﻿using SqlSugar;
using System.Reflection;

namespace commonManagement.Infrstructre
{
    public class SqlSugarDbcontext
    {
        protected readonly ISqlSugarClient db;
        public SqlSugarDbcontext(ISqlSugarClient db)
        {
            this.db = db;
        }
        public void CreateDatabase()
        {
            db.DbMaintenance.CreateDatabase();
            var rootpath = AppDomain.CurrentDomain.BaseDirectory;
            Type[] types = Assembly.LoadFrom(rootpath + "ERPPublic.dll").GetTypes().Where(it => it.FullName.Contains("ERPPublic.eneity")).ToArray();

            db.CodeFirst.SetStringDefaultLength(200).InitTables(types);
        }

        public void createDataBase()
        {
            throw new NotImplementedException();
        }
    }
}
